<?php slot('contents') ?>
  <?php if($productPictures->count() > 1): ?>
    <script type="text/javascript" src="/web/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" href="/web/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
    <script type="text/javascript">
      $(document).ready(function() {
        $('.fancy-pictures').fancybox({
    			'transitionIn'		: 'fade',
    			'transitionOut'		: 'fade',
    			'titlePosition' 	: 'over',
    			'overlayColor'		: '#000',
    			'showCloseButton' : 'true',
    			'showNavArrows'   : 'true',
    			'overlayOpacity'	: 0.8,
    			'overlayShow'     : 'true',
          'hideOnOverlayClick' : 'true',
          'hideOnContentClick' : true
        });

        $('.product-tab').click(function() {
          location.href = $(this).children('a').attr('href');
        });
      });
    </script>
  <?php endif;?>
  <div class="breadcrumbs"><?php include_component('headerMenu', 'breadCrumbs') ?></div>

  <!--// Loading layer -->
  <div id="loading-lahendus">
    <div>
      <img src="/web/img/70.gif" alt="Loading..." />
      <span>Loading ...</span>
    </div>
  </div>
  <!--// End of loading layer -->

  <table cellpadding="0" cellspacing="0" style="width: 600px">
      <tr>
        <td class="first" align="left" valign="middle"><h1><?php echo $product->getName() ?></h1></td>
        <td class="second" align="right" valign="middle"><a href="<?php echo LinkGen::getInstance(LinkGen::PRODUCT)->link($product->getId()) ?>/productPage/print" target="_blank"><img src="/web/img/print.png" alt="Print" /></a>  <div style="float: right;" class="addthis_toolbox addthis_default_style ">
<a href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=xa-4d7fd30b003a4ca5" class="addthis_button_compact"><img src="/web/img/share.png" style="margin-left: 15px;" alt="Share" /></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4d7fd30b003a4ca5"></script></td>
      </tr>
      <tr>
        <td colspan="2">
          <!--// Product tabs -->
          <div class="product-tab-container">
            	<div class="product-tab-background">
                	<div class="product-tab<?php echo !$active ? ' product-is-active' : '' ?>">
                    	<a href="<?php echo LinkGen::getInstance(LinkGen::PRODUCT)->link($product->getId()) ?>" <?php echo !$active ? ' class="active"' : '' ?>><?php echo __('Info') ?></a>
                        <div class="arrow<?php echo !$active ? '-is-active' : '' ?>"></div>
                    </div>
                    <div class="product-tab">
                    	<a href="#"><?php echo __('Koosta lahendus') ?></a>
                        <div class="arrow"></div>
                    </div>
                    <?php if($tabs): ?>
                      <?php foreach($tabs as $tab): ?>
                        <div class="product-tab<?php echo ($tab->getParameter()->getId() == $active) ? ' product-is-active' : ''; ?>">
                      	<a href="<?php echo LinkGen::getInstance(LinkGen::PRODUCT)->link($product->getId()) ?>?id=<?php echo $tab->getParameter()->getId() ?>" <?php echo ($tab->getParameter()->getId() == $active) ? ' class="active"' : ''; ?>><?php echo $tab->getParameter()->getName() ?></a>
                          <div class="arrow<?php echo ($tab->getParameter()->getId() == $active) ? '-is-active' : ''; ?>"></div>
                        </div>
                      <?php endforeach; ?>
                    <?php endif; ?>
                    <div class="product-tab-end"></div>
                </div>
          </div>
          <!--// Zoom button -->
          <div class="zoom-container">
          	<a href="" id="zoom"><img src="/web/img/zoom.png" alt="Enlarge image" /></a>
          </div>
          </td>
      </tr>
      <tr>
        <td colspan="2">
        	<div>
            	<div class="p-container">
                	<div class="p-contents-container">
                    <?php if($sf_request->getParameter('act') != 'lahendus'): ?>
                    	<p>
                        <?php if(isset($value) && $value): ?>
                          <?php if($value->getParameter()->getType() == 'PICTURE'): ?>
                            <img src="/web/uploads<?php echo $value->getValue() ?>" alt="" />
                          <?php else: ?>
                            <p><?php echo $value->getValue() ?></p>
                          <?php endif; ?>
                        <?php else: ?>
                          <?php if($product->getDescription()): ?>
                            <?php echo nl2br($product->getDescription()); ?>
                          <?php else: ?>
                            <?php echo __('No description is available') ?>
                          <?php endif; ?>
                        <?php endif; ?>
                      </p>
                    <?php else: ?>










              
              <style type="text/css">
              .p-contents-container { padding-left:0 }
              </style>
              <script type="text/javascript">
                $(document).ready(function() {
                  $('.nested').first().css({
                    display : 'block'
                  });

                  // Handle parameter click
                  $('.l-cnt-container').click(function() {
                    var found = false;
                    
                    // Collect all the information
                    var invoke = {
                      group  : $(this).parent().prev().prev().prev(),
                      param  : $(this),
                      target : false
                    }

                    // Close all groups bellow
                    $('.l-cnt-container[id^="group"]').each(function() {
                      alert('aaaaaaaa');
                    });
                    

                    $('.l-container').each(function(){
                      if(found) {
                        // Found ..
                        invoke.target = $(this);
                      } else {
                        if($(this).get(0) == invoke.group.get(0)) {
                          found = true;
                        }
                      }
                    });

                    if(invoke.group && invoke.param && invoke.target) {
                      var url = '?invoke=' + invoke.group.attr('id') + '&target=' + invoke.target.attr('id') + '&param=' + invoke.param.attr('id');

                      var coords = {
                        top  : (($(window).height() + $(window).scrollTop()) / 2) - (75),
                        left : (($(window).width() + $(window).scrollLeft()) / 2) - (175)
                      }
                      // Show loading layer before request
                      $('#loading-lahendus').css({
                        top  : coords.top,
                        left : coords.left
                      });

                      $('#loading-lahendus').fadeIn('slow', function() {
                        // Send AJAX request
                        $.get('/index.php/action/productPage/ajax' + url , function(data) {
                          var redraw = $('#' + invoke.target.attr('id'));

                          $('#loading-lahendus').fadeOut('slow', function() {
                            if(redraw) {
                              var redrawTarget = redraw.next().next().next();

                              // Draw big picture
                              $('.p-picture').fadeOut('slow', function() {
                                var paramId    = invoke.param.attr('id').match(/[0-9]+$/);
                                var bigPicture = $('#enlarge-id-' + paramId);

                                $(this).html(bigPicture.parent().html()).fadeIn('slow', function() {
                                  redrawTarget.css({display : 'block'});
                                  redrawTarget.html(data);
                                  redrawTarget.css({display : 'none'});
                                  redrawTarget.slideDown('slow')
                                });
                              });
                            }
                          });
                        })
                      });
                    }
                  });
                });
              </script>
              <?php foreach($groups as $j => $group): ?>
              <!--// Koosta lahendus -->
              <div<?php echo $j ? ' style="margin-top: 10px"' : '' ?>
                <!--// Switcher -->
                
                  <div class="l-container" id="group-<?php echo$group['ParameterGroup']['id'] ?>">
                    <div class="l-left"></div>
                    <div class="l-middle">
                      <div>
                        <div class="l-txt-left"><span><?php echo$group['ParameterGroup']['Translation'][$sf_user->getCulture()]['name'] ?></span></div>
                        <div class="l-txt-right"><span></span></div>
                      </div>
                      <div class="l-arrow"></div>
                    </div>
                  </div>
                <div class="l-right"></div>
                <div class="cls"></div>
                <?php if(!$j): ?>
                <!--// Contents -->
                <div class="nested">
                  <?php foreach($parameter as $param): ?>
                    <div class="l-cnt-container" id="main-<?php echo $param['id'] ?>">
                      <div class="l-cnt-general">
                        <div class="l-img"><img src="/web/uploads/lahendus/<?php echo $param['small_image'] ?>" alt="" /></div>
                        <div>
                          <div class="l-cnt-arrow"></div>
                          <div><span><?php echo $param['Translation'][$sf_user->getCulture()]['name'] ?></span></div>
                        </div>
                      </div>
                      <div style="display: none"><img src="/web/uploads/lahendus/<?php echo $param['big_image'] ?>" alt="" id="enlarge-id-<?php echo $param['id'] ?>" /></div>
                    </div>
                  <?php endforeach ?>
              </div>
                <?php endif; ?>
                <div class="cls"></div>
              </div>
              <?php endforeach ?>
              
















































                    <?php endif; ?>
                    </div>
                    <div class="p-left-line"></div>
                    <div class="p-right-line"></div>
                </div>
                <div class="p-picture">
                  <?php if($productPictures->count() > 1): ?>
                    <?php if($productPictures->count() >= 2):  // Slideshow is available ?>
                      <?php $pic = $productPictures->toArray() ?>
                      <a href="#open" class="fancy-pictures" rel="fancy-pictures" id="open"><img src="/web/uploads<?php echo $pic[1]['file'] ?>" alt="" /></a>
                    <?php else:  // No, we have only the first picture ?>
                      <img src="/web/uploads<?php echo $productPictures->getFirst()->getFile() ?>" />
                    <?php endif; ?>
                  <?php else: ?>
                    <img src="/web/uploads<?php echo $product->getBrandPicture() ?>" />
                  <?php endif; ?>
                </div>
            </div>
           <div class="term"></div>
        </td>
      </tr>
      <?php if($product->video_link): ?>
        <tr>
          <td colspan="2" style="padding-top: 20px;" align="left">
            <div style="margin: 0 20px 20px 0; text-align: left; float: left;"><iframe title="YouTube video player" width="426" height="240" src="<?php echo $product->video_link ?>" frameborder="0" allowfullscreen></iframe></div>
            <div><p><?php echo nl2br($product->longdescription) ?></p></div>
          </td>
        </tr>
      <?php endif; ?>
    </table>
    <div style="display: none">
      <?php foreach($productPictures as $j => $picture): ?>
        <?php if($j <= 1) continue ?>
        <a class="fancy-pictures" rel="fancy-pictures" href="/web/uploads<?php echo $picture->getFile() ?>"></a>
      <?php endforeach; ?>
    </div>
<?php end_slot() ?>